import cn.hutool.core.io.file.FileReader;
import com.google.common.base.Strings;
import util.Const;
import util.CreateUtil;

public class CreateNormal {

    static final String FILA_NAME = "sharecode.txt";

    //定义 东东农场 jd_fruit 互助
    static String[] jd_fruit_list = new String[20];

    //定义 东东萌宠 jd_pet 互助
    static String[] jd_pet_list = new String[20];

    //定义 种豆得豆 jd_plantBean互助
    static String[] jd_plantBean_list = new String[20];

    //定义 东东工厂 jd_jdfactory互助
    static String[] jd_factory_list = new String[20];

    //定义 京喜工厂 jd_dreamFactory互助
    static String[] jd_dreamFactory_list = new String[20];

    //定义 京喜农场 jd_jxnc互助
    static String[] jd_jxnc_list = new String[20];

    //定义 京东赚赚 jd_jdzz互助
    static String[] jd_jdzz_list = new String[20];

    //定义 crazyJoy jd_crazy_joy互助
    static String[] jd_crazy_joy_list = new String[20];

    //定义 闪购盲盒 jd_sgmh互助
    static String[] jd_sgmh_list = new String[20];

    //定义 财富岛 jd_cfd互助
    static String[] jd_cfd_list = new String[20];

    //定义 签到领现金 jd_cash_joy互助
    static String[] jd_cash_list = new String[20];


    public static void main(String[] args) {
        FileReader fileReader = new FileReader(FILA_NAME);

        String text = fileReader.readString();
        String[] split = text.split("结束======");

        int maxNum = split.length - 1;

        String startFlag = "开始======";
        String endFlag = "======账号";

        for (int i = 0; i < split.length; i++) {
            String userText = split[i];
            //第一次循环  账号 i
            if (userText.contains("获取互助码, 结束")) {
                break;
            }
            String user = userText.substring(userText.indexOf(startFlag) + startFlag.length(),
                    userText.lastIndexOf(endFlag));
            String[] userCodeTextArray = user.split("\r\n");
            for (String userCodeText : userCodeTextArray) {
                if (Strings.isNullOrEmpty(userCodeText) || !userCodeText.contains("】")) {
                    continue;
                }
                String code = userCodeText.substring(userCodeText.indexOf("】") + 1);
                if (userCodeText.contains(Const.Fruit)) {
                    jd_fruit_list[i] = code;
                } else if (userCodeText.contains(Const.Pet)) {
                    jd_pet_list[i] = code;
                } else if (userCodeText.contains(Const.Bean)) {
                    jd_plantBean_list[i] = code;
                } else if (userCodeText.contains(Const.JdFactory)) {
                    jd_factory_list[i] = code;
                } else if (userCodeText.contains(Const.DreamFactory)) {
                    jd_dreamFactory_list[i] = code;
                } else if (userCodeText.contains(Const.Jxnc)) {
                    jd_jxnc_list[i] = code;
                } else if (userCodeText.contains(Const.Jdzz)) {
                    jd_jdzz_list[i] = code;
                } else if (userCodeText.contains(Const.Joy)) {
                    jd_crazy_joy_list[i] = code;
                } else if (userCodeText.contains(Const.Sgmh)) {
                    jd_sgmh_list[i] = code;
                } else if (userCodeText.contains(Const.Cfd)) {
                    jd_cfd_list[i] = code;
                } else if (userCodeText.contains(Const.Cash)) {
                    jd_cash_list[i] = code;
                }
            }
        }
        CreateUtil.createJdMy(Const.Fruit, jd_fruit_list, maxNum);
        CreateUtil.createJdMy(Const.Pet, jd_pet_list, maxNum);
        CreateUtil.createJdMy(Const.Bean, jd_plantBean_list, maxNum);
        CreateUtil.createJdMy(Const.JdFactory, jd_factory_list, maxNum);
        CreateUtil.createJdMy(Const.DreamFactory, jd_dreamFactory_list, maxNum);
        CreateUtil.createJdMy(Const.Jxnc, jd_jxnc_list, maxNum);
        CreateUtil.createJdMy(Const.Jdzz, jd_jdzz_list, maxNum);
        CreateUtil.createJdMy(Const.Joy, jd_crazy_joy_list, maxNum);
        CreateUtil.createJdMy(Const.Sgmh, jd_sgmh_list, maxNum);
        CreateUtil.createJdMy(Const.Cfd, jd_cfd_list, maxNum);
        CreateUtil.createJdMy(Const.Cash, jd_cash_list, maxNum);
    }



}
